layui.use(['form', 'layer'], function () {
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;

    /**
     * 添加或更新计划项
     */
    form.on("submit(addOrUpdateCusDevPlan)",function (data) {
        //弹出loading层
        var index=top.layer.msg("数据提交中请稍后",{icon:16,time:false,
        shade:0.8});
        var url=ctx+"/cus_dev_plan/save";
        var id=$("input[name='id']").val();
        console.log("sssss"+id);
        if(id){
            url=ctx+"/cus_dev_plan/update";
        }

        $.post(url,data.field,function (result){
            if(result.code==200){
                setTimeout(function () {
                    // 关闭弹出层（返回值为index的弹出层)
                    top.layer.close(index);
                    top.layer.msg("操作成功！");
                    //关闭所有iframe层
                    layer.closeAll("iframe");
                    //刷新父页面
                    parent.location.reload();
                },500);
            }else {
                layer.msg(result.msg,{icon:5});
            }
        });

        return false;
    })
    

});